﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;

namespace BHair.Base
{
    public partial class frmfllist : Form
    {
        public frmfllist()
        {
            InitializeComponent();
        }
        string constr = ConfigurationManager.ConnectionStrings["BHair.Properties.Settings.BHairDBConnectionString"].ConnectionString;
        private void frmfllist_Load(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sqlstr = "SELECT [ID] ,[type] FROM [商品分类]";
            DataSet ds = new DataSet();
            SqlDataAdapter sda = new SqlDataAdapter(sqlstr,conn);
            sda.Fill(ds, "商品分类");
            gridControl1.DataSource = ds.Tables["商品分类"];
            conn.Close();
        }
        public void jz()
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sqlstr = "SELECT [ID] ,[type] FROM [商品分类]";
            DataSet ds = new DataSet();
            SqlDataAdapter sda = new SqlDataAdapter(sqlstr, conn);
            sda.Fill(ds, "商品分类");
            gridControl1.DataSource = ds.Tables["商品分类"];
            conn.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            chuanzhi.flup =0;
            frmspfl fl = new frmspfl();
            fl.ShowDialog();
            jz();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            chuanzhi.flid=Int32.Parse( gridView1.GetFocusedRowCellValue("ID").ToString());
            chuanzhi.flname = gridView1.GetFocusedRowCellValue("type").ToString();
            chuanzhi.flup = 1;
            frmspfl fl = new frmspfl();
            if (fl.ShowDialog() == DialogResult.OK)
            {
                //this.LoadMemberList();
                
            }
            jz();

        }

        private void button3_Click(object sender, EventArgs e)
        {
            //删除
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sqlstr =string.Format( "DELETE FROM [商品分类] WHERE ID={0}",Int32.Parse( gridView1.GetFocusedRowCellValue("ID").ToString()));
            SqlCommand comm = new SqlCommand(sqlstr,conn);
            comm.ExecuteNonQuery();
            MessageBox.Show("删除成功");
            jz();
        }
    }
}
